package com.my.user.service.impl;

import com.my.common.domain.UserAddress;
import com.my.common.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

//dubbo暴露服务
@com.alibaba.dubbo.config.annotation.Service//(weight = 100)//设置权重
@Service
public class UserServiceImpl2 implements UserService {
    @Value("${dubbo.protocol.port}")
    private Integer dubboPort;

    public List<UserAddress> getList(Integer id) {
        System.out.println("[" + dubboPort + "]用户id="+id);
        List<UserAddress> list = new ArrayList<>();
        list.add(new UserAddress(1,"北京","张三","12345678","Y"));
        list.add(new UserAddress(2,"上海","李四","22345678","N"));

        if(Math.random()<0.5){
           // throw new RuntimeException("模拟发生异常...");
        }
        return list;
    }
}
